﻿using HomagChina.CCT.Views;
using HomagGroup.Base.UI;
using Proxy;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Threading;

namespace HomagChina.CCT.ViewModels
{
    public class PartsInfoViewModel : HomagGroup.Base.UI.NotifyPropertyChangedBase
    {
        #region Handle
        private CommonHandle commonHandle;
        private DeleteInfoHandle Handle_Delete;
        private SearchInfoHandle Handle_Search;

        public RelayCommand EditCommand { get; }
        public RelayCommand DeleteCommand { get; }
        public RelayCommand SearchCommand { get; }
        public RelayCommand UnLoadedCommand { get; }
        public RelayCommand LoadedCommand { get; }
        #endregion Handle

        #region 属性
        private string reference;
        public string Reference
        {
            get => reference;
            set { reference = value; Query(); OnPropertyChanged(); }
        }

        private ObservableCollection<BoardInfoModel> _List_BoardInfoModel;

        public ObservableCollection<BoardInfoModel> List_BoardInfoModel
        {
            get => _List_BoardInfoModel;
            set { _List_BoardInfoModel = value; OnPropertyChanged(); }
        }


        private DispatcherTimer UpdateSessionTimer;
        #endregion 属性

        #region 构造函数
        public PartsInfoViewModel()
        {
            commonHandle = new CommonHandle();
            //Handle_Delete = new DeleteInfoHandle();
            //EditCommand = new RelayCommand(HandleEditCommand);
            Handle_Search = new SearchInfoHandle();
            SearchCommand = new RelayCommand(Query);
            Query();
        }

        /// <summary>
        /// Unloaded
        ///
        /// </summary>
        private void ViewUnloadedCommand()
        {
            UpdateSessionTimer.Stop();
        }

        public void Query()
        {
            List_BoardInfoModel = Handle_Search.GetPartsInfo(Reference);
        }
        #endregion 构造函数

        #region 函数

        /// <summary>
        ///
        /// </summary>
        /// <param name="obj"></param>
        public void HandleEditCommand(object SelectItem)
        {

        }

        /// <summary>
        /// 打开弹窗
        /// </summary>
        public void OpenDialog(object data)
        {

        }
    }
    #endregion 函数
}